package com.jay.tools.glide;

import android.content.Context;

import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;

/**
 * author: tanjianpei
 * date: 2018/8/29 029 13:12
 * <p>
 * description:
 */
public class GlideOptions {


    public static final RequestOptions applyOption(Context context, int width, int height) {
        return new RequestOptions()
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .dontAnimate()
                .override(dp2px(context, width), dp2px(context, height));
    }

    private static int dp2px(Context context, int dp) {
        return (int) (dp * context.getResources().getDisplayMetrics().density + 0.5f);
    }

}
